<?php
/**
 * Created by PhpStorm.
 * User: zhangxinke
 * Date: 2019/5/31
 * Time: 15:06
 */

namespace app\api\model;

use think\Db;
class BindingModel extends BaseModel{

    public function weiadd($name,$uid,$number,$files){//微信绑定
        return Db::name('wechat')->insert([
            'uid'=>$uid,
            'name'=>$name,
            'number'=>$number,
			'qrcode'=>$files,
            'createtime'=>time()
        ]);
    }
    public function zhiadd($name,$uid,$number,$files){//支付宝绑定
        return Db::name('alipay')->insert([
            'uid'=>$uid,
            'name'=>$name,
            'number'=>$number,
			'qrcode'=>$files,
            'createtime'=>time()
        ]);
    }
    public function banklist(){//查询全部银行
        return Db::name('open_bank')->select();
    }
	public function upload($file){//上传图片
		$fileName = md5(time());
            $fileRoute = ROOT_PATH . '/upload/bind/';
            // 创建文件夹
            if (!file_exists($fileRoute)) {
                mkdir($fileRoute);
            }
            $info = $file->move($fileRoute, $fileName);
            if ($info) {
                // 缩略图
                $photo = '/upload/bind/'.$info->getFilename();

            } else {
                // 上传失败获取错误信息
                return $file->getError();
            }
        return $photo;
	}
	public function bankbind($uid,$open_bank,$name,$number,$branch){
		return Db::name('bank')->insert([
            'uid'=>$uid,
            'name'=>$name,
            'number'=>$number,
			'open_bank'=>$open_bank,
			'branch'=>$branch,
            'createtime'=>time()
        ]);
	}
}